﻿@{
    Layout = "~/Views/_LayoutPage1.cshtml";
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title></title>
</head>
<body>
    <input type="hidden" id="hidsex" value="@ViewBag.model.sex" />
    <input type="hidden" id="pbid" value="@ViewBag.pbid" />
  
    <div id="root">
        <div data-reactroot="">
            <div class="ui-alert" id="showmsg" style="display:none">
                <div class="text" id="showtext">请正确填写手机号码</div>
            </div>
        <div class="page-add-patient">
            @*<div class="add-patient-label">选择就诊人类型</div>*@
        @*<div class="select-patient-type">
            <div class="select-patient-item">
                <img src="https://front-images.oss-cn-hangzhou.aliyuncs.com/i4/61dfbb94f0f5f337937cde067f33547f-68-68.png">
                <div style="margin-left: 40px;">
                    <div>成年人</div>
                    <div>(本人身份证)</div>
                </div>
                <div class="patient-select-icon" style="background-image: url(&quot;https://front-images.oss-cn-hangzhou.aliyuncs.com/i4/ea85a99901bc3f7490c98d3555aef2a0-56-56.png&quot;);"></div>
            </div>
        </div>*@
            <div class="add-patient-label" style="padding-top: 15px;">填写就诊人信息</div>
            <div class="ui-form">
                <div class="ui-form-item ui-form-item-show  ui-border-b">
                    <label>姓名:</label>
                    <input type="text" id="patientName" maxlength="20" value="@ViewBag.model.brxm"   placeholder="请输入就诊人姓名">
                </div>
                <div class="ui-form-item ui-form-item-show  ui-border-b">
                    <label>性别:</label>
                   
                    <select id="sex" style="margin-left:95px; width:60%">

                        <option value="0"></option>
                        <option value="1">男</option>
                        <option value="2">女</option>
                    </select>
                  
                    
                </div>
                <div class="ui-form-item ui-form-item-show ui-border-b">
                    <label>手机号码:</label><input type="number" value="@ViewBag.model.sjhm" id="J_Phone" placeholder="就诊人手机号码">
                </div>
                <div class="ui-form-item ui-form-item-show ui-border-b" id="J_idNo">
                    <label>身份证:</label>
                    @if (string.IsNullOrEmpty(ViewBag.model.sfzh))
                    {
                        <input type="text"  id="idNo" maxlength="25" placeholder="请输入证件号码">
                    }
                    else
                    {
                        <input type="text" value="@ViewBag.model.sfzh" class="txt-info" readonly="" id="idNo" maxlength="25" placeholder="请输入证件号码">
                    }
                   
                    @*<img src="~/Content/img/ishow.png" class="id-toggle" data-spm="see" data-spm-id="100.1502.1000.see">*@
                </div>
                <div class="ui-form-item ui-form-item-switch ui-border-b">
                    <p class="checkbox-name">设为默认就诊人</p>
                    <label class="ui-switch">
                        @if (ViewBag.model.isdefault == 1)
                        {
                            <input type="checkbox" id="J_Default" checked="checked">
                        }
                        else
                        {
                            <input type="checkbox" id="J_Default">
                        }
                    
                    </label>
                </div>
            </div>
            <div>
                      @*<div id="J_PatientCard">
                          <div class="add-patient-label" style="padding-top: 15px;">就诊卡管理</div>
                          <div class="ui-form ui-medical-card">
                              <ul class="list-ord">
                                  <li class="list-item ">
                                      <a class="txt-arrowlink list-link-wrapper" data-spm-id="100.1502.1000.1">
                                          <img src="//image.yuantutech.com/user/a3ab8a00d7ded4af13c304446051fc7a-92-92.png" class="list-icon">
                                          <div class="list-content">
                                              <div class="list-title txt-prompt">尚未绑定，请先绑定就诊卡</div>
                                          </div>
                                      </a>
                                  </li>
                              </ul>
                          </div>
                      </div>*@
            </div>
            <div class="panel g-space notice-top" id="J_BindCardTip">
                <div class="panel-title">温馨提示：</div>
                <div class="panel-msg patient-notice-msg">
                    <p>1. 就诊人姓名、身份证号将用于医院建档信息匹配，请输入正确的就诊人姓名和身份证号；</p><p>2.添加就诊人后预约，取号时需使用与此处填写的就诊人身份证号和姓名相匹配的就诊卡，否则无法取号；</p>
                    @*<p>3.无身份证儿童请选择“儿童”类型添加就诊人。</p>*@
                </div>
            </div><div class="fixed-foot-wrapper">
            <div class="btn-wrapper g-footer">
            <button class="btn btn-secondary btn-lg" id="J_DeleteBtn">删除就诊人</button>
            <button class="btn btn-lg" id="J_SubmintBtn">确认编辑</button></div></div>

            <div class="modal-mask" style="display:none">
                <div class="modal-wrapper">
                    <div class="modal">
                        <div class="modal-title">删除就诊人后，所有医疗服务数据也一并删除，确认要删除吗？</div>
                        <div class="modal-body txt-insign "></div>
                        <div class="modal-footer">
                            <div class="modal-button-group-h">
                                <a class="modal-button" onclick="delbrxx(1)" >取消</a>
                                <a class="modal-button" onclick="delbrxx(2)" >确认</a>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        </div>
    </div>

    <script>
        $("#sex").val($("#hidsex").val());

        function delbrxx(type) {
            if (type == 1) {
                $(".modal-mask").hide();
            } else {
                $.post("/UserInfo/delbrxx", { "sfzh": $("#idNo").val() }, function () {

                    window.location.href = "/UserInfo/Index";
                })
            }
        }

        $("#J_DeleteBtn").click(function () {
            $(".modal-mask").show();
        })

        $("#J_SubmintBtn").click(function () {

            
            var userinfo = {
                sfzh: $("#idNo").val(),
                sex: $("#sex").val(),
                sjhm: $("#J_Phone").val(),
                brxm: $("#patientName").val(),
                isdefault: $("#J_Default")[0].checked==false?0:1
            }
          

            if (userinfo.sex == "" || userinfo.sfzh.length < 15) {
                $("#showmsg").show();
                $("#showtext").text("请输入正确的身份证号")
                setInterval(function () {
                    $("#showmsg").hide();
                    return false;
                }, 3000)


            } else {
                if (userinfo.sex == "" || userinfo.sex == "0") {
                    $("#showmsg").show();
                    $("#showtext").text("请填写性别")
                    setInterval(function () {
                        $("#showmsg").hide();
                        return false;
                    }, 3000)


                } else {
                    if (userinfo.brxm == "") {
                        $("#showmsg").show();
                        $("#showtext").text("请填写姓名")
                        setInterval(function () {
                            $("#showmsg").hide();
                            return false;
                        }, 3000)


                    } else {
                        if (userinfo.sjhm == "" || userinfo.sjhm.length != 11) {
                            $("#showmsg").show();
                            $("#showtext").text("请输入正确的手机号码")
                            setInterval(function () {
                                $("#showmsg").hide();
                                return false;
                            }, 3000)


                        } else {
                            $.post("/UserInfo/insbrxx", userinfo, function (result) {
                                if (result == 0) {
                                    window.location.href = "/UserInfo/Index?pbid=" + $("#pbid").val();
                                } else {
                                    alert(result);
                                }
                               
                            })
                        }
                    }
                }
            }

           
        })

    </script>
</body>
</html>
